home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / bash / bash_108 / bash-108.zoo / bash-1.08 / general.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-17  |  1.8 KB  |  79 lines

  1. /* general.h -- defines that everybody likes to use. */
  2.  
  3. #if !defined (_GENERAL_)
  4. #define _GENERAL_
  5.  
  6. #if !defined (NULL)
  7. #define NULL 0x0
  8. #endif
  9.  
  10. #ifndef savestring
  11. #define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x))
  12. #endif
  13.  
  14. #ifndef whitespace
  15. #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
  16. #endif
  17.  
  18. #ifndef digit
  19. #define digit(c)  ((c) >= '0' && (c) <= '9')
  20. #endif
  21.  
  22. #ifndef isletter
  23. #define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
  24. #endif
  25.  
  26. #ifndef digit_value
  27. #define digit_value(c) ((c) - '0')
  28. #endif
  29.  
  30. #if !defined (__STDC__)
  31. char *index (), *rindex ();
  32. #endif
  33.  
  34. #ifndef member
  35. #define member(c, s) (int)((c) ? index ((s), (c)) : 0)
  36. #endif
  37.  
  38. /* String comparisons that possibly save a function call each. */
  39. #define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
  40. #define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)
  41.  
  42. /* Function pointers can be declared as (Function *)foo. */
  43. #ifndef __FUNCTION_DEF
  44. typedef int Function ();
  45. #define __FUNCTION_DEF
  46. #endif
  47.  
  48. /* The output of `signal' is different on different systems.  Yechh. */
  49. #if !defined (VOID_SIGHANDLER)
  50. #  if defined (_POSIX_HANDLER) || (SunOS4) || defined (NeXT) || defined (Ultrix) || defined (USG)
  51. #    define VOID_SIGHANDLER
  52. #  endif
  53. #endif
  54.  
  55. #if defined (VOID_SIGHANDLER)
  56. #define sighandler void
  57. #else
  58. #define sighandler int
  59. #endif
  60.  
  61. typedef sighandler SigHandler ();
  62.  
  63. #define NOW    ((time_t) time ((time_t *) 0))
  64.  
  65. /* Definitions to set file descriptors to close-on-exec, the Posix way. */
  66. #if !defined (FD_CLOEXEC)
  67. #define FD_CLOEXEC    1
  68. #endif
  69.  
  70. #define FD_NCLOEXEC    0
  71.  
  72. #define SET_CLOSE_ON_EXEC(fd)    (fcntl ((fd), F_SETFD, FD_CLOEXEC))
  73. #define SET_OPEN_ON_EXEC(fd)    (fcntl ((fd), F_SETFD, FD_NCLOEXEC))
  74.  
  75. extern char *xmalloc (), *malloc (), *xrealloc (), *realloc ();
  76. extern char *itos ();
  77.  
  78. #endif    /* _GENERAL_ */
  79.